<?php session_start();?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <LINK REL=StyleSheet HREF="maintenancePagesCSS.css" TYPE="text/css" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
<?php

print("

<html>
    <head>
        <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
        <title></title>
    </head>
    <body>
        <center>
");

include "Datasource.php";
include "ProductDetails.php";
include "ProductDetailsDao.php";

//create connection to database
$connection = new Datasource("localhost","theanykey","root","");
//print("DS Good"); //Used for testing

//create dao object to interact with database
$productDetailsDao = new ProductDetailsDao();
//print("DAO Good"); //Used for testing

//create new customer valueObject and populate with data from post
$part = new ProductDetails();
$part->setAll($_POST["PK"], $_POST["Manufacturer"],
    $_POST["ModelNo"], $_POST["SerialNo"],
    $_POST["CompanyPrice"], $_POST["CustomerPrice"],
    $_POST["TechNotes"]);

//print("Part Good"); //Used for testing
//send valueObject to dao so that it can be added to database
if($productDetailsDao->save($connection, &$part))
{

//Use db count method to return the valueObject from db with PK
//still dont know if this will always work
//$part = $productDetailsDao->getObject($connection, $productDetailsDao->countAll($connection));



//print($customer->toString()); //Used for testing


?>
            <div align="center">
      <table width="1000" height="566" border="0" background="images/background.jpg">
                <tr>
                  <th height="431" scope="col"><p><img src="images/TitleProductInformation.gif" alt="Product Information" width="514" height="67"></p>
                    <table border="0" class="SelectTable">
                      <tbody>
                        <tr>
                          <td>Manufacturer:</td>
                          <td><?php print($part->getManufacturer());  ?></td>
                        </tr>
                        <tr>
                          <td>Model Number:</td>
                          <td><?php print($part->getModelNo());  ?></td>
                        </tr>
                        <tr>
                          <td>Serial Number:</td>
                          <td><?php print($part->getSerialNo());  ?></td>
                        </tr>
                        <tr>
                          <td>Company Price:</td>
                          <td><?php print($part->getCompanyPrice());  ?></td>
                        </tr>
                        <tr>
                          <td>Customer Price:</td>
                          <td><?php print($part->getCustomerPrice());  ?></td>
                        </tr>
                        <tr>
                          <td>Tech Notes:</td>
                          <td><?php print($part->getTechNotes());  ?></td>
                        </tr>
                        <tr>
                          <td colspan=2> <div align="center"><U>Product has  been successfully updated.</U> </div></td>
                        </tr>
                      </tbody>
                    </table>
                    <?php
            }//end if
            else
            {
                ?>
                    <font style="color: Red">Please go back and try again.</font> <br/>
                    <br/>
                    <?php
            }

            ?>
                    <br>
                    <br>
                    <script src="links.js" language="javascript" type="text/javascript"></script>
                    <script type="text/javascript">
            writeProductLinks("ProductSearch.php", "Edit Another Part");
                    </script>
                    </center></th>
                </tr>
                <tr>
                  <th height="129" scope="col">&nbsp;</th>
                </tr>
              </table>
              <p>&nbsp;</p>
            </div>
</body>
</html>
